	<tr>
		<th id="nom">Factures</th>
<% ( @test.Tcols[:ids].length * 2 + 4).times do %>
		<td></td>
<% end %>
	</tr>	

<% @factures.each do |facture| %>
	<% fact = @test.Tfactures[facture.id] %>
	<% nb_parcelles = facture.parcelles.length %>
	
	<tr align=left>
		<td><%= nb_parcelles %> p - <%= pretty(fact[:surface_total]) %> ha</td>
		<td>
			<%= fact[:id] %> - 
			<%= link_to facture.name, edit_facture_path(facture) %> - 
			<%= fact[:category] %>
		</td>	
	<% if facture.diff? %>	
		<td><%= pretty(facture.cout) %> - <%= pretty(facture.sum_charges) %> = <%= pretty(fact[:cout_total]) %></td>
	<% else %>	
		<td></td>
	<% end %>	
		<td><%= pretty(fact[:cout_ha]) %> €/ha</td>
		<td><%= pretty(fact[:cout_total]) %> €</td>
	
	<% @test.Tcols[:ids].each do |id| %>
		<% cout_ha = get_value_or_blank(fact[id], "cout_ha") %>
		<% cout_total = get_value_or_blank(fact[id], "cout_total") %>
		<% td_class = odd(@test.Tcols[id][:rang]) %>
		<td class="<%= td_class %>"><%=h cout_ha %></td>
		<td class="<%= td_class %>"><%=h cout_total %></td>
	<% end %>
	</tr>
<% end %>

<!-- Total Facture "type" (maison, invest, agri) -->
<% for type in @types %>
	<tr id="subtotal" align=left>
		<td id="nom"><b><%= type.name %></b></td>
		<td></td>
		<td></td>
		<td></td>
		<td><%= pretty(@test.Tfactures[:cout_total][type.name]) %></td>	
	<% @test.Tcols[:ids].each do |id| %>
		<% cout_ha = pretty(@test.Tcols[id][:total][:cout_ha][type.name]) %>
		<% cout_total = pretty(@test.Tcols[id][:total][:cout_total][type.name]) %>
		<% td_class = odd(@test.Tcols[id][:rang]) %>
			<td class="<%= td_class %>"><%= cout_ha %></td>
			<td class="<%= td_class %>"><%= cout_total %> </td>
	<% end %>
	</tr>
<% end %>

<!-- Total Facture -->
	<tr id="subtotal" align=left>
		<td id="nom">Total Facture:	</td>
		<td></td>	
		<td></td>
		<td></td>
		<td><%= pretty(@test.Tfactures[:cout_total][:sum]) %></td>	
	<% @test.Tcols[:ids].each do |id| %>
		<% cout_ha = pretty(@test.Tcols[id][:factures][:cout_ha][:sum]) %>
		<% cout_total = pretty(@test.Tcols[id][:factures][:cout_total][:sum]) %>
		<% td_class = odd(@test.Tcols[id][:rang]) %>
			<td class="<%= td_class %>_subtotal"><%= cout_ha %></td>
			<td class="<%= td_class %>_subtotal"><%= cout_total %></td>
	<% end %>
	</tr>

	